package logic

import (
	"context"
	"xialou_platform/services/agent/rpc/agentClient"
	"xialou_platform/services/agent/rpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type AgentDataLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAgentDataLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AgentDataLogic {
	return &AgentDataLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 代理数据
func (l *AgentDataLogic) AgentData(in *agentClient.AgentDataReq) (*agentClient.AgentDataResp, error) {
	return &agentClient.AgentDataResp{
		UserNum:  l.svcCtx.AgentUserModel.FindBindUserCount(l.ctx, in.AgentId),
		StoreNum: l.svcCtx.StoreModel.FindListCount(l.ctx, "", "", 1, in.AgentId, false),
		TeamSize: l.svcCtx.AgentModel.FindTeamSize(l.ctx, in.Type, in.AgentId),
	}, nil
}
